﻿using System;
using System.Collections.Generic;
using System.Text;

using pgy8288.Common;
namespace pgy8288.SqlServerSlap
{
    class Program
    {
        static void Main(string[] args)
        {
            // Console.WriteLine(pgy8288.Common.BaseInfo.HELP_TEXT);
            // ThreadControl th = new ThreadControl();

#if DEBUG
            args = new string[14] { "--start-threads=4"
                , "--total-queries=20000"
                //, "--create-database=sql"
                , "--database=sql"
                , "--username=sa"
                , "--password=123456"
                , "--host=localhost"
                , "--int-column-num=2"
                , "--nchar-column-num=1"
                , "--varchar-column-num=2"
                , "--datetime-column-num=2"
                , "--auto-create-primary-key=1"
            , "--insert-num=2000"
            , "--delete-num=2000"
            , "--update-num=2000"};

            string executeCmd="进入了调试模式，调试模式的参数是由开发人员指定的，外部指定参数无效\r\n";
                executeCmd += "SqlServerSlap.exe ";
            for (int i = 0; i < args.Length; i++)
                executeCmd += " " + args[i];

                Console.WriteLine(executeCmd);
            
#endif
            ExecResultInfo result = pgy8288.Common.SysParams.ProcessParams(args);
            if (result.ID <= 0)
            {
                Console.WriteLine(result.Message);
                return;
            }
            result = InitSystem.Init();
            if (result.ID <= 0)
            {
                Console.WriteLine(result.Message);
                if (result.EX != null)
                {
                    Console.WriteLine("");
                    Console.WriteLine(result.EX.Message);
                }
                return;
            }

            if (result.ID > 0)
                ThreadControl.ThreadStress(args);
        }
        
    }
}
